#ifndef _HKVFS_H_
#define _HKVFS_H_

#include <time.h>
#include <stdint.h>
#define MAX_FILE_NAME_LEN 128U
struct Inode {
        int64_t length;
        //int32_t uid;
        //int32_t gid;
        //int32_t mode;
        //uint64_t ctime;           /* time of last status change */
        uint64_t mtime;             /* time of last modification */
        //uint64_t atime;           /* time of last access */
        int64_t blocks[12];         /* the first 8KB*12=96KB */
        int64_t iblock;             /* the next 8KB/8*8KB=8MB */
        int64_t doubly_iblock;      /* the next 8K/8*8K/8*8K=8GB */
        int64_t triply_iblock;      /* the next 8K/8*8K/8*8K/8*8K=8TB */
}__attribute__((packed));

struct super_block {
    uint32_t seg_size;                                  /* max segment size */
    uint32_t block_size;                        /* max data block size */
    uint64_t max_fs_size;               /* max filesystem size */
    char fsname[MAX_FILE_NAME_LEN];             /* record the file's name */
};


#define LOG_HEADER_LENGTH sizeof(struct log_header)
/*
struct write_req{
    char * req_buf;
    uint32_t db_start;
    uint32_t db_end;
};
struct write_rsp{
    int res;
    uint64_t size;
};
*/

/* The control structure in RAM */
struct hlfs_ctrl {
    struct   super_block sb;                    /* the sb in RAM */
    struct   Inode inode;
    uint32_t last_segno;                                    /* the current segment */
    uint32_t last_offset;                                   /* the current offset in current segment */
    struct   back_storage *storage;
    void *   last_wsegfile_handler;
    void *   last_rsegfile_handler;
    uint32_t last_read_segno;
    uint32_t last_rsegfile_offset;          /* last segfile end offset when last open */
    //GAsyncQueue * write_req_aqueue;
    //GAsyncQueue * write_rsp_aqueue;
    //struct write_rsp  write_rsp;
    //struct write_req  write_req;
    uint64_t last_write_timestamp;
    uint64_t last_read_timestamp;
    //int seg_clean_run;
    int rw_inode_flag;
    char alive_ss_name[MAX_FILE_NAME_LEN];
};

typedef struct hkvfs_stat{
       uint32_t seg_size;                                       /* max segment size */
       uint32_t block_size;                     /* max data block size */
       uint64_t max_fs_size;               /* max filesystem size */
       char fsname[MAX_FILE_NAME_LEN];          /* record the file's name */
       uint32_t last_segno;
       uint32_t last_offset;
}HKVFS_STAT_T;

#endif
